package com.s59.service;

import com.s59.entity.User;
import com.s59.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public Long add(User user){
        return userMapper.save(user).getId();
    }

    public int del(Long id){
        userMapper.deleteById(id);
        return 1;
    }


    public Long update(User user){
        return userMapper.save(user).getId();
    }

    public User get(Long id) {
        return userMapper.findById(id).get();
    }

    public List<User> getall(){
        return userMapper.findAll();
    }
}
